import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path(.*)',
        component: () => import('@/views/redirect/index')
      }
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  {
    path: '/auth-redirect',
    component: () => import('@/views/auth-redirect'),
    hidden: true
  },
  {
    path: '/404',
    component: () => import('@/views/error/404'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('@/views/error/401'),
    hidden: true
  },
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index'),
        meta: { title: '首页', icon: 'dashboard', affix: true }
      }
    ]
  },
  {
    path: '/profile',
    component: Layout,
    redirect: '/profile/index',
    hidden: true,
    children: [
      // {
      //   path: 'index',
      //   component: () => import('@/views/profile/index'),
      //   name: 'Profile',
      //   meta: { title: '个人中心', icon: 'user', noCache: true }
      // },
      {
        path: 'changepassword',
        component: () => import('@/views/profile/changepassword'),
        name: 'Profile',
        meta: { title: '修改密码', icon: 'user', noCache: true }
      }
    ]
  },
  // {
  //   path: '/msg',
  //   component: Layout,
  //   hidden: true,
  //   children: [
  //     {
  //       path: 'dispose/msg',
  //       component: (resolve) => require(['@/views/system/msg/disposeMsg'], resolve),
  //       name: 'DisposeMsg',
  //       meta: { title: '消息处理', icon: '' }
  //     }
  //   ]
  // },
  // {
  //   path: '/job',
  //   component: Layout,
  //   hidden: true,
  //   children: [
  //     {
  //       path: 'log',
  //       component: (resolve) => require(['@/views/monitor/job/log'], resolve),
  //       name: 'JobLog',
  //       meta: { title: '调度日志' }
  //     }
  //   ]
  // },
  //  答题页面
  {
    path: '/answer',
    component: (resolve) => require(['@/views/question/answer'], resolve),
    hidden: true
  },
  {
    path: '/joblog',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'log',
        component: (resolve) => require(['@/views/common/job/log'], resolve),
        name: 'JobLog',
        meta: { title: '调度日志' }
      }
    ]
  },
  //  阅卷页面
  {
    path: '/read-paper-form',
    component: (resolve) => require(['@/views/exam/read-paper/form/readPaperForm'], resolve),
    hidden: true
  },
  //  考试提交后页面
  {
    path: '/simulate-submit',
    component: (resolve) => require(['@/views/question/answer/form/simulateSubmitForm'], resolve),
    hidden: true
  },
  // 模拟test：path路径与页面路径一致，可以在dialog或新页面中分别获取参数
  {
    path: '/common/msg/test',
    component: () => import('@/views/common/msg/test'),
    hidden: true
  },
]

const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher
}

export default router

// 平台菜单
export const asyncRoutes = [
  /*{
    path: '/question',
    name: '/question',
    component: Layout,
    alwaysShow: true,
    meta: { title: '题库建设', icon: 'sb', roles: ['admin'] },
    children: [
      {
        path: 'project',
        name: 'Project',
        component: () => import('@/views/question/projectinfo/index'),
        meta: { title: '立项管理', icon: 'list', roles: ['admin'] }
      },
      {
        path: 'question-bank',
        name: 'QuestionBank',
        component: () => import('@/views/question/question-bank/index'),
        meta: { title: '题库管理', icon: 'list', roles: ['admin'] }
      },
      {
        path: 'question',
        name: 'Question',
        component: () => import('@/views/question/question/index'),
        meta: { title: '试题管理', icon: 'list', roles: ['admin'] }
      },
      {
        path: 'paper',
        name: 'Paper',
        component: () => import('@/views/question/paper/index'),
        meta: { title: '组卷管理', icon: 'list', roles: ['admin'] }
      },
      {
        path: 'specialty',
        name: 'Specialty',
        component: () => import('@/views/question/specialty/index'),
        meta: { title: '专业树管理', icon: 'list', roles: ['admin'] }
      },
      {
        path: 'dept-coding',
        name: 'DeptCoding',
        component: () => import('@/views/question/deptcoding/index'),
        meta: { title: '部门代号管理', icon: 'list', roles: ['admin'] }
      },
    ]
  },
  {
    path: '/exam',
    name: '/exam',
    component: Layout,
    alwaysShow: true,
    meta: { title: '考试管理', icon: 'sb', roles: ['admin'] },
    children: [
      {
        path: 'sign-up',
        name: 'signUp',
        component: () => import('@/views/exam/signup/index'),
        meta: { title: '报名管理', icon: 'list', roles: ['admin'] }
      },
      {
        path: 'exam-plan',
        name: 'ExamPlan',
        component: () => import('@/views/exam/exam-plan/index'),
        meta: { title: '考试计划管理', icon: 'list', roles: ['admin'] }
      },
      {
        path: 'exam-room',
        name: 'ExamRoom',
        component: () => import('@/views/exam/exam-room/index'),
        meta: { title: '考场管理', icon: 'list', roles: ['admin'] }
      },
      {
        path: 'read-paper',
        name: 'readPaper',
        component: () => import('@/views/exam/read-paper/index'),
        meta: { title: '阅卷管理', icon: 'list', roles: ['admin'] }
      },
      {
        path: 'score',
        name: 'Score',
        component: () => import('@/views/exam/score/index'),
        meta: { title: '成绩管理', icon: 'list', roles: ['admin'] }
      }
    ]
  },
  {
    path: '/cert',
    name: '/cert',
    component: Layout,
    alwaysShow: true,
    meta: { title: '取证管理', icon: 'sb', roles: ['admin'] },
    children: [
      {
        path: 'certInfo',
        name: 'CertInfo',
        component: () => import('@/views/cert/certinfo/index'),
        meta: { title: '证书管理', icon: 'list', roles: ['admin'] }
      }
    ]
  },
  {
    path: '/assess',
    name: '/assess',
    component: Layout,
    alwaysShow: true,
    meta: { title: '评估管理', icon: 'sb', roles: ['admin'] },
    children: [
      {
        path: 'continuous-assessment',
        name: 'continuousAssessment',
        component: () => import('@/views/assess/continuous-assessment/index'),
        meta: { title: '持续评估', icon: 'list', roles: ['admin'] }
      },
      {
        path: 'matrix-evaluation',
        name: 'matrixEvaluation',
        component: () => import('@/views/assess/matrix-evaluation/index'),
        meta: { title: '矩阵评估', icon: 'list', roles: ['admin'] }
      },
      {
        path: 'general-ability',
        name: 'generalAbility',
        component: () => import('@/views/assess/general-ability/index'),
        meta: { title: '通用能力配置', icon: 'list', roles: ['admin'] }
      }
    ]
  },*/
  {
    path: '/statistics',
    name: '/statistics',
    component: Layout,
    alwaysShow: true,
    meta: { title: '数据统计', icon: 'sb', roles: ['admin'] },
    children: [
      {
        path: 'certdata',
        name: 'certdata',
        component: () => import('@/views/statistics/certdata/index'),
        meta: { title: '证书统计', icon: 'list', roles: ['admin'] }
      },
      {
        path: 'questiondata',
        name: 'questiondata',
        component: () => import('@/views/statistics/question/index'),
        meta: { title: '试题统计', icon: 'list', roles: ['admin'] }
      },
      {
        path: 'bank',
        name: 'bank',
        component: () => import('@/views/statistics/bank/index'),
        meta: { title: '题库统计', icon: 'list', roles: ['admin'] }
      },
      {
        path: 'test',
        name: 'test',
        component: () => import('@/views/statistics/test/index'),
        meta: { title: '考试统计', icon: 'list', roles: ['admin'] }
      }
    ]
  },
  /*{
    path: '/basic-manage',
    name: '/basic-manage',
    component: Layout,
    alwaysShow: true,
    meta: { title: '基础数据管理', icon: 'sb', roles: ['admin'] },
    children: [
      {
        path: 'filetab',
        name: 'Filetab',
        component: () => import('@/views/basicdata/basictype/index'),
        meta: { title: '数据字典管理', icon: 'dict', roles: ['admin'] }
      },
      {
        path: 'empolyee-manage',
        name: 'Empolyeectrl',
        component: () => import('@/views/resource/basicempolyee/index'),
        meta: { title: '人员信息管理', icon: 'peoples', roles: ['admin'] }
      }
    ]
  },*/
  {
    path: '/platform',
    name: '/platform',
    component: Layout,
    alwaysShow: true,
    meta: { title: '系统管理', icon: 'system', roles: ['admin'] },
    children: [
      {
        path: 'account-manage',
        name: 'AccountCtrl',
        component: () => import('@/views/platformctrl/accountCtrl/index'),
        meta: { title: '账号管理', icon: 'user', roles: ['admin'] }
      },
      {
        path: 'role-manage',
        name: 'RoleCtrl',
        component: () => import('@/views/platformctrl/roleCtrl/index'),
        meta: { title: '角色管理', icon: 'peoples', roles: ['admin'] }
      },
      {
        path: 'permission-manage',
        name: 'PermissionCtrl',
        component: () => import('@/views/platformctrl/permissionCtrl/index'),
        meta: { title: '按钮权限管理', icon: 'icon', roles: ['admin'] }
      },
      {
        path: 'org-tree',
        name: 'OrgTree',
        component: () => import('@/views/platformctrl/orgTree/index'),
        meta: { title: '组织机构管理', icon: 'tree', roles: ['admin'] }
      },
      {
        path: 'job',
        name: 'Job',
        component: () => import('@/views/common/job/index'),
        meta: { title: '调度任务', icon: 'tree', roles: ['admin'] }
      },
      {
        path: 'msg',
        name: 'Msg',
        component: () => import('@/views/common/msg/index'),
        meta: { title: '通知消息', icon: 'tree', roles: ['admin'] }
      },
      {
        path: 'log',
        name: 'Log',
        component: () => import('@/views/common/log/index'),
        meta: { title: '操作日志', icon: 'tree', roles: ['admin'] }
      }
    ]
  },
  /*{
    path: '/task',
    name: '/task',
    component: Layout,
    alwaysShow: true,
    meta: { title: '任务管理', icon: 'sb', roles: ['admin'] },
    children: [
      {
        path: 'todo-task',
        name: 'todoTask',
        component: () => import('@/views/workflow/todoTask'),
        meta: { title: '待办任务', icon: 'tree', roles: ['admin'] }
      },
      {
        path: 'have-done',
        name: 'haveDone',
        component: () => import('@/views/workflow/haveDone'),
        meta: { title: '已办任务', icon: 'tree', roles: ['admin'] }
      }
    ]
  }*/
]
